{% extends "layout.html" %}
{% from 'bootstrap/form.html' import render_form %}

{% block content %}

<div class="container">
    <h5>{{ users|length }} messages
        <small class="float-right">
            <a href="#bottom" title="Go Bottom">&darr;</a>
        </small>
    </h5>
    <div class="list-group">
        {% for user in users %}
            <a class="list-group-item list-group-item-action flex-column">
                <div class="d-flex w-100 justify-content-between">
                    <h5 class="mb-1 text-success">{{ user.username }}
                        <small class="text-muted"> #{{ loop.revindex }}</small>
                    </h5>
                    <small data-toggle="tooltip" data-placement="top"
                           data-timestamp="{{ user.created_at.strftime('%Y-%m-%dT%H:%M:%SZ') }}"
                           data-delay="500">
                    </small>
                </div>
                <p class="mb-1">active: {{ user.active }}</p>
                <p class="mb-1">created in: {{ user.created_at.strftime('%Y-%m-%d %H:%M:%S') }}</p>
                {% if user.active %}
                    {% if not user.is_admin %}
                        <a href="{{ url_for('admin.cancleactive', username=user.username) }}" style="margin-top: 12px"><button class="btn-danger">Cancel Active</button></a>
                    {% endif %} 
                {% else %}
                    {% if not user.is_admin %}
                        <a href="{{ url_for('admin.addactive', username=user.username) }}" style="margin-top: 12px"><button class="btn-success">Add Active</button></a>
                    {% endif %}    
                {% endif %}
                <br>
                <!-- <a href="/"><button {% if user.active %}disabled="disabled"{% endif %}>is_active</button></a> -->
        {% endfor %}

        <a href="{{ url_for('admin.add_all_active') }}" style="margin-top: 12px"><button class="btn-success">Add ALL Active</button></a>
        <br>
        <a href="{{ url_for('admin.cancle_all_active') }}"><button class="btn-danger">Cancel ALL Active</button></a>

    </div>
</div>
{% endblock %}